package com.mephi.gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
import com.mephi.util.Constants;

/**
 * Class responsible for setting backgrounds according to move's strength
 * @author GM Mephisto
 * @version 1.0 2011-0504
 */
public class MoveDefaultRenderer extends JLabel implements TableCellRenderer
{
	
	public MoveDefaultRenderer()
	{
		this(null, null, null, null, null, null, null, null);
	}
	
	/**
	 * @param strongMoveFont
	 * @param veryStrongMoveFont
	 * @param weakMoveFont
	 * @param blunderMoveFont
	 * @param strongMoveBackground
	 * @param veryStrongMoveBackground
	 * @param weakMoveBackground
	 * @param blunderMoveBackground
	 */
	public MoveDefaultRenderer(Font strongMoveFont, Font veryStrongMoveFont,
			Font weakMoveFont, Font blunderMoveFont,
			Color strongMoveBackground, Color veryStrongMoveBackground,
			Color weakMoveBackground, Color blunderMoveBackground)
	{
		super();
		this.strongMoveFont = strongMoveFont;
		this.veryStrongMoveFont = veryStrongMoveFont;
		this.weakMoveFont = weakMoveFont;
		this.blunderMoveFont = blunderMoveFont;
		this.strongMoveBackground = strongMoveBackground;
		this.veryStrongMoveBackground = veryStrongMoveBackground;
		this.weakMoveBackground = weakMoveBackground;
		this.blunderMoveBackground = blunderMoveBackground;
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int col)
	{
		if (((String)value).contains(Constants.EXCLAMATION_MARK))
		{
			setOpaque(true); 
			setBackground(Color.GREEN);
		}
		return this;
	}
	
	/**
	 * @return the strongMoveFont
	 */
	public Font getStrongMoveFont()
	{
		return strongMoveFont;
	}

	/**
	 * @param strongMoveFont the strongMoveFont to set
	 */
	public void setStrongMoveFont(Font strongMoveFont)
	{
		this.strongMoveFont = strongMoveFont;
	}

	/**
	 * @return the veryStrongMoveFont
	 */
	public Font getVeryStrongMoveFont()
	{
		return veryStrongMoveFont;
	}

	/**
	 * @param veryStrongMoveFont the veryStrongMoveFont to set
	 */
	public void setVeryStrongMoveFont(Font veryStrongMoveFont)
	{
		this.veryStrongMoveFont = veryStrongMoveFont;
	}

	/**
	 * @return the weakMoveFont
	 */
	public Font getWeakMoveFont()
	{
		return weakMoveFont;
	}

	/**
	 * @param weakMoveFont the weakMoveFont to set
	 */
	public void setWeakMoveFont(Font weakMoveFont)
	{
		this.weakMoveFont = weakMoveFont;
	}

	/**
	 * @return the blunderMoveFont
	 */
	public Font getBlunderMoveFont()
	{
		return blunderMoveFont;
	}

	/**
	 * @param blunderMoveFont the blunderMoveFont to set
	 */
	public void setBlunderMoveFont(Font blunderMoveFont)
	{
		this.blunderMoveFont = blunderMoveFont;
	}

	/**
	 * @return the strongMoveBackground
	 */
	public Color getStrongMoveBackground()
	{
		return strongMoveBackground;
	}

	/**
	 * @param strongMoveBackground the strongMoveBackground to set
	 */
	public void setStrongMoveBackground(Color strongMoveBackground)
	{
		this.strongMoveBackground = strongMoveBackground;
	}

	/**
	 * @return the veryStrongMoveBackground
	 */
	public Color getVeryStrongMoveBackground()
	{
		return veryStrongMoveBackground;
	}

	/**
	 * @param veryStrongMoveBackground the veryStrongMoveBackground to set
	 */
	public void setVeryStrongMoveBackground(Color veryStrongMoveBackground)
	{
		this.veryStrongMoveBackground = veryStrongMoveBackground;
	}

	/**
	 * @return the weakMoveBackground
	 */
	public Color getWeakMoveBackground()
	{
		return weakMoveBackground;
	}

	/**
	 * @param weakMoveBackground the weakMoveBackground to set
	 */
	public void setWeakMoveBackground(Color weakMoveBackground)
	{
		this.weakMoveBackground = weakMoveBackground;
	}

	/**
	 * @return the blunderMoveBackground
	 */
	public Color getBlunderMoveBackground()
	{
		return blunderMoveBackground;
	}

	/**
	 * @param blunderMoveBackground the blunderMoveBackground to set
	 */
	public void setBlunderMoveBackground(Color blunderMoveBackground)
	{
		this.blunderMoveBackground = blunderMoveBackground;
	}

	/**
	 * @return the serialVersionUID
	 */
	public static long getSerialVersionUID()
	{
		return serialVersionUID;
	}


	private Font strongMoveFont = null;
	private Font veryStrongMoveFont = null;
	private Font weakMoveFont = null;
	private Font blunderMoveFont = null;
	
	private Color strongMoveBackground = null;
	private Color veryStrongMoveBackground = null;
	private Color weakMoveBackground = null;
	private Color blunderMoveBackground = null;
	
	private static final long serialVersionUID = 245042064126361513L;
}
